package br.com.diogenesistemas.dinggle.command;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Diógenes
 */
public abstract class AbstractCommand implements Command{

    public abstract String onExecute(HttpServletRequest request);

    public void execute(HttpServletRequest request, HttpServletResponse response) {
        String caminho = onExecute(request);
        
        try {
            request.getRequestDispatcher(caminho).forward(request, response);
        } catch (ServletException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
